package com.example.kiutils;

import java.io.IOException;

import com.kigkrazy.kiutils.ZipUtils;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity {
	private Button btnDecompress;
	private Button btnCompress;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		btnDecompress = (Button) findViewById(R.id.btnDecompress);
		
		btnDecompress.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				String zipFilePath = "/data/local/tmp/1.zip";
				String unzipDir = "/data/local/tmp/unziptest";
				try {
					ZipUtils.decompressZip(zipFilePath, unzipDir);
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
			}
		});
		
		
		btnCompress = (Button) findViewById(R.id.btnCompress);
		btnCompress.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				String zipFilePath = "/data/local/tmp/unziptest/2.zip";
				String unzipDir = "/data/local/tmp/unziptest/1";
				try {
					ZipUtils.compress(unzipDir, zipFilePath);
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
			}
		});
	}
}
